﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using WebChatService.Models;

namespace WebChatSerivce.Models
{
    public class ChatterMessageEFDB : IDatabase
    {
        WebChatEntities db = new WebChatEntities();
        public WebChatBaseModel GetSingleObject(int id)
        {
            return db.ChatterMessages.Find(id);
        }

        public IEnumerable<WebChatBaseModel> GetAllObjects()
        {
            return db.ChatterMessages.AsEnumerable();
        }

        public void AddObject(WebChatBaseModel model)
        {
            db.ChatterMessages.Add((ChatterMessage)model);
        }

        public void UpdateObject(WebChatBaseModel model)
        {
            db.Entry((ChatterMessage)model).State = EntityState.Modified;
        }

        public void RemoveObject(WebChatBaseModel model)
        {
            db.ChatterMessages.Remove((ChatterMessage)model);
        }

        public void SaveChanges()
        {
            db.SaveChanges();
        }

        public void Dispose()
        {
            db.Dispose();
        }
    }
}